package myproject.computer;

import java.util.Scanner;

/**
 * @author shkstart
 * @creat 2022-04-22:04
 */
public class Test {
    public static void main(String[] args) {
        boolean isStart = false;//标志电脑是否启动
        boolean isFormat = false;//标志电脑是否格式化
        boolean isOS = false;//标志电脑是否安装操作系统
        Scanner sc = new Scanner(System.in);
        Computer pc = new Computer("小米", "银色", "1024*1024", 4999, 300000);
        System.out.println(pc.toString());
        computer:
        while (true) {
            System.out.println("           1.启动");
            System.out.println("           2.格式化");
            System.out.println("           3.安装操作系统");
            System.out.println("           4.安装软件");
            System.out.println("           5.下载软件");
            System.out.println("           6.查看各盘情况");
            System.out.println("           7.退出");
            System.out.println("请选择：");
            int no = sc.nextInt();
            switch (no) {
                case 1: {
                    isStart = pc.start();
                    if (isStart) {
                        System.out.println(pc.getBrand() + "电脑启动成功");
                    }
                    break;
                }
                case 2: {
                    if (!isStart) {
                        System.out.println("先去启动电脑");
                        break;
                    }
                    System.out.print("计划分成几个盘：");
                    int num = sc.nextInt();
                    for (int i = 0; i < num; i++) {
                        System.out.println("请输入第" + (i + 1) + "盘符名和大小");
                        isFormat = pc.formate(pc.addDisk(sc.next(), sc.nextInt()));
                        System.out.println("电脑剩余内存：" + pc.getSurplusCapacity() + "MB");
                        if (!isFormat) {
                            break;
                        }
                    }
                    if (isFormat) {
                        System.out.println("格式化成功");
                    } else {
                        System.out.println("电脑内存不足");
                    }
                    break;
                }
                case 3: {
                    if (!isStart) {
                        System.out.println("先去启动电脑");
                        break;
                    }
                    if (!isFormat) {
                        System.out.println("先去格式化电脑");
                        break;
                    }

                    System.out.println("请选择操作系统：win7 / win10 / win11 :");
                    String OSName = sc.next();
                    System.out.println("请选择安装的盘：");
                    String diskName = sc.next();
                    isOS = pc.addOS(OSName, diskName);

                    break;
                }
                case 4: {
                    if (!isStart) {
                        System.out.println("先去启动电脑");
                        break;
                    }
                    if (!isFormat) {
                        System.out.println("先去格式化电脑");
                        break;
                    }
                    if (!isOS) {
                        System.out.println("先去安装操作系统");
                        break;
                    }
                    System.out.println("1.普通软件、2.下载软件");
                    int choose = sc.nextInt();
                    System.out.print("软件名称：");
                    String wareName = sc.next();
                    System.out.print("软件大小：");
                    int wareSize = sc.nextInt();
                    SoftWare softWare = pc.chooseSoftWare(choose, wareName, wareSize);
                    System.out.print("安装位置：");
                    pc.install(sc.next(), softWare);
                    break;
                }
                case 5: {
                    if (!isStart) {
                        System.out.println("先去启动电脑");
                        break;
                    }
                    if (!isFormat) {
                        System.out.println("先去格式化电脑");
                        break;
                    }
                    if (!isOS) {
                        System.out.println("先去安装操作系统");
                        break;
                    }
                    System.out.println("请选择一个下载软件：");
                    String downWareName = sc.next();
                    System.out.println("想要下载的软件名称：");
                    String wareName = sc.next();
                    System.out.println("软件大小");
                    int wareSize = sc.nextInt();
                    System.out.println("请输入安装的盘符：");
                    String diskName = sc.next();
                    boolean isDown = pc.download(downWareName, wareName, wareSize, diskName);
                    if (!isDown) {
                        System.out.println("安装失败");
                    }
                    break;
                }
                case 6: {
                    if (!isStart) {
                        System.out.println("先去启动电脑");
                        break;
                    }
                    if (!isFormat) {
                        System.out.println("先去格式化电脑");
                        break;
                    }
                    if (!isOS) {
                        System.out.println("先去安装操作系统");
                        break;
                    }
                    System.out.println("请输入盘符：");
                    pc.read(sc.next());
                    break;
                }
                case 7: {
                    System.out.println("退出");
                    break computer;
                }
            }

        }
    }
}
